home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Libris Britannia 4
/
science library(b).zip
/
science library(b)
/
CUGUK
/
APPLICAT
/
C034.ZIP
/
DBQTBL.C
< prev
next >
Wrap
Text File
|
2010-11-01
|
3KB
|
181 lines
/* SDB - table output routine */
#include "bdscio.h"
#include "dbqdefs.h"
#define BINSRT(chr) buffer[bndx++] = chr
db_thead(fp,slptr)
FILE *fp; struct sel *slptr;
{
struct sattr *saptr;
int twidth,fwidth,i;
char *aname;
dbv_lnct = dbv_pgln;
dbv_page++;
twidth = 0;
for (saptr = slptr->sl_attrs; saptr != NULL; saptr = saptr->sa_next)
twidth += saptr->sa_attr->at_size + 2;
if (dbv_pgln < 1000) fprintf(fp,"[ Page: %d ]\n",dbv_page);
bstart();
BINSRT('\n'); /* Blank line for spacing */
for (saptr = slptr->sl_attrs; saptr != NULL; saptr = saptr->sa_next) {
fwidth = saptr->sa_attr->at_size;
if ((aname = saptr->sa_name) == NULL)
aname = saptr->sa_aname;
/* Uppercase with _ changed to spaces */
for (i = 0; i < fwidth; i++)
if (*aname != 0)
BINSRT(toheading(*aname++));
else
BINSRT(' ');
BINSRT(' ');
BINSRT(' ');
}
bprint(fp);
bstart();
for (i = 0; i < twidth; i++)
BINSRT('=');
bprint(fp);
}
int toheading(ch)
char ch;
{
if (ch == '_')
return (' ');
else
return (toupper(ch));
}
db_tfoot(fp,slptr)
FILE *fp; struct sel *slptr;
{
struct sattr *saptr;
int twidth,i;
char tempst[22]; char *tptr;
twidth = 0;
for (saptr = slptr->sl_attrs; saptr != NULL; saptr = saptr->sa_next)
twidth += saptr->sa_attr->at_size + 2;
bstart();
for (i = 0; i < twidth; i++)
BINSRT('=');
bprint(fp);
/* Now print totals */
bstart();
for (saptr = slptr->sl_attrs; saptr != NULL; saptr = saptr->sa_next) {
if (saptr->sa_total != NULL) {
/* flform(saptr->sa_total,saptr->sa_attr->at_size,-1); */
ltoas(&tempst,saptr->sa_total,saptr->sa_attr->at_scale);
tptr = &tempst;
i = saptr->sa_attr->at_size - strlen(tptr);
if (i > 0) while (i--) BINSRT(' ');
while (*tptr)
BINSRT(*tptr++);
BINSRT(' ');
BINSRT(' ');
}
else {
i = saptr->sa_attr->at_size + 2;
while (i--) BINSRT(' ');
}
}
bprint(fp);
}
db_tentry(fp,slptr)
FILE *fp; struct sel *slptr;
{
struct sattr *saptr;
int fwidth,i;
char *temptr,tempfl[4];
if (dbv_lnct == 0) {
fputs("\n\n",fp);
db_thead(fp,slptr);
}
dbv_lnct--;
bstart();
for (saptr = slptr->sl_attrs; saptr != NULL; saptr = saptr->sa_next) {
fwidth = saptr->sa_attr->at_size;
temptr = &buffer[bndx];
for (i = 0; i < fwidth; i++)
if (saptr->sa_aptr[i] != 0) {
BINSRT(saptr->sa_aptr[i]);
}
else {
BINSRT(' ');
}
BINSRT(' ');
BINSRT(' ');
buffer[bndx] = EOS;
if (saptr->sa_total != NULL) {
atols(tempfl,temptr,saptr->sa_attr->at_scale);
ladd(saptr->sa_total,saptr->sa_total,tempfl);
}
}
bprint(fp);
}
bstart()
{
bndx = 0;
}
/* replaced by macro
binsert(ch)
int ch;
{
if (ch)
if (bndx < TABLEMAX)
buffer[bndx++] = ch;
}
*/
bprint(fp)
FILE *fp;
{
buffer[bndx] = EOS;
fprintf(fp,"%s\n",buffer);
}
/* Long field print routine
lform(longint,width,scale)
char longint[];
int width, scale;
{
char wbuf[20];
char *wptr;
int i,j;
wptr = wbuf;
ltoas(wbuf,longint,scale);
i = width - strlen(wbuf);
if (i > 0)
while (i--)
binsert(' ');
while (*wptr)
binsert(*wptr--);
}
*/
le);
i = width - strlen(wbuf);
if (i > 0)
while (i--)
bins